package io.singulart.particle_progress_bar;

import ohos.agp.render.Canvas;
import ohos.agp.render.Paint;
import ohos.agp.utils.Color;
import ohos.agp.utils.Point;

public class Ball {
    private Paint mPaint;
    private float mSize;

    private Point mPosition;
    private int mColor;

    private double mAngle;

    Ball(float size, int color, double angle) {
        this.mSize = size;
        this.mAngle = angle;
        this.mColor = color;
        init();
    }

    private void init() {
        initPaint();
        initPoint();
    }

    private void initPaint() {
        mPaint = new Paint();
        mPaint.setColor(new Color(mColor));
        mPaint.setAntiAlias(true);
        mPaint.setSubpixelAntiAlias(true);
    }

    private void initPoint() {
        if (mPosition == null) {
            mPosition = new Point();
        }
    }

    /**
     * get Angle
     *
     * @return double
     */
    public double getAngle() {
        return mAngle;
    }

    /**
     * get Paint
     *
     * @return Paint
     */
    public Paint getPaint() {
        return mPaint;
    }

    /**
     * set Paint
     *
     * @param paint Paint
     */
    public void setPaint(Paint paint) {
        this.mPaint = paint;
    }

    /**
     * get Color
     *
     * @return int
     */
    public int getColor() {
        return mColor;
    }

    /**
     * set Color
     *
     * @param color int
     */
    public void setColor(int color) {
        this.mColor = color;
    }

    /**
     * get Size
     *
     * @return float
     */
    public float getSize() {
        return mSize;
    }

    /**
     * set Size
     *
     * @param size float
     */
    public void setSize(float size) {
        this.mSize = size;
    }

    /**
     * get Position
     *
     * @return Point
     */
    public Point getPosition() {
        return mPosition;
    }

    /**
     * set Position
     *
     * @param xx double
     * @param yy double
     */
    public void setPosition(double xx, double yy) {
        this.mPosition.modify((float) xx, (float) yy);
    }

    void render(Canvas canvas) {
        canvas.drawCircle(mPosition.getPointX(), mPosition.getPointY(), mSize, mPaint);
    }
}
